<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        parent
        <child></child>
    </div>
    <script src="vue.js"></script>
    <script>
        Vue.mixin = function(mixinObj){
            this.options =  window.mergeOptions(this.options,mixinObj);
            return this;
        }
        //Vue的mixin方法接收一个对象参数，对象其实就是Vue的参数对象
        //参数就是一个混入对象，将会混入到每一个Vue创建的实例中
        Vue.mixin({
            beforeCreate(){
                console.log(this.name,'beforeCreate')
            },
            created(){
                console.log(this.name,'created')
            }
        })
        //你在混入对象中定义的任何选项都将被混入到创建的每一个Vue实例中,包括根实例和所有的组件实例
        var vm = new Vue({
            el:'#app',
            data(){return {name:'parent'}},
            components:{
                child:{
                    data(){return {name:'child'}},
                    template:'<div>child</div>'
                }
            }
        });
    </script>
</body>
</html>